<template>
	<div class="app-container">

		<el-table :data="data.list" :header-cell-style="{ 'text-align': 'center' }"
			:cell-style="{ 'text-align': 'center' }" class="w-full">

			<el-table-column prop="trade_no" :label="$t('marketing.preferential.orderCode')" show-overflow-tooltip />

			<el-table-column prop="machine_id" :label="$t('machine.code')" show-overflow-tooltip />

			<el-table-column prop="price" :label="$t('marketing.guess.unitPrice') + '/' + $t('marketing.guess.total')"
				show-overflow-tooltip>
				<template #default="scope">
					{{ scope.row.price }} / {{ scope.row.total_price }}
				</template>
			</el-table-column>

			<el-table-column prop="quantity" :label="$t('marketing.guess.drawsNum')" show-overflow-tooltip />

			<el-table-column prop="active_type" :label="$t('marketing.guess.type')" show-overflow-tooltip>
				<template #default="scope">
					<el-tag v-if="scope.row.active_type == 1" type="warning">{{ $t('marketing.guess.Single') }}</el-tag>
					<el-tag v-else type="success">{{ $t('marketing.guess.continuous') }}</el-tag>
				</template>
			</el-table-column>

			<el-table-column prop="status" :label="$t('marketing.guess.lotteryStatus')" show-overflow-tooltip>
				<template #default="scope">
					<el-tag v-if="scope.row.status == 1" type="info">{{ $t('marketing.guess.Waiting') }}</el-tag>
					<el-tag v-if="scope.row.status == 2" type="success">{{ $t('public.used') }}</el-tag>
					<el-tag v-if="scope.row.status == 3" type="warning">{{ $t('public.expired') }}</el-tag>
					<el-tag v-if="scope.row.status == 4" type="danger">{{ $t('public.invalid') }}</el-tag>
				</template>
			</el-table-column>

			<el-table-column prop="used_date" :label="$t('date.lotteryDate')" show-overflow-tooltip>
				<template #default="scope">
					{{ level.gettime(scope.row.used_date, 1) }}
				</template>
			</el-table-column>



		</el-table>

		<PageNum :total="data.total" :page="data.lotery" @exposeData="current" @fraction="fraction" />

	</div>
</template>

<script lang="ts" setup>
import { useI18n } from 'vue-i18n'
const { t: $t } = useI18n()
import PageNum from '@/components/PageNum/index.vue';
import level from "@/utils/level";
import { getlotusedList } from '@/api/marketing';
import { useRoute } from "vue-router";
const route = useRoute()
let data = reactive({
	mtloading: false, // 加载
	list: [], // 列表信息
	lotery: { // 筛选数据
		page: 1,
		pageNum: 15
	},
	total: 0, // 总条数
})

// 获取列表信息
let getlist = () => {
	let info = JSON.parse(decodeURI(route.query.l)).info
	data.lotery.al_id = info.al_id
	data.mtloading = true
	getlotusedList(data.lotery).then(res => {
		data.mtloading = false
		if (res.state == 200) {
			data.list = res.data.data
			data.total = res.data.total
		}
	})
}

// 页数回调
let current = (e) => {
	data.lotery.page = e
	getlist()
}

// 条数回调
let fraction = (e) => {
	data.lotery.pageNum = e
	getlist()
}

getlist()

</script>
